n = int(input())
N = int (1e5 + 5)
stack = [0 for i in range(0, N)]
top = 0
for i in range(0, n):
    s = input()
    if s == 'Ctrl+Z':
        if top > 0:
            top = top - 1
    else :
        top = top + 1
        stack[top] = s
for i in range(1, top):
    print(stack[i], end = '/')
print(stack[top])